package com.team.sion.mapper;

import com.team.sion.pojo.Singer;
import com.team.sion.pojo.SingerExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface SingerMapper {
    long countByExample(SingerExample example);

    int deleteByExample(SingerExample example);

    @Delete({
        "delete from singer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into singer (id, name, ",
        "sex, pic, birth, ",
        "location, introduction)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{sex,jdbcType=VARCHAR}, #{pic,jdbcType=VARCHAR}, #{birth,jdbcType=DATE}, ",
        "#{location,jdbcType=VARCHAR}, #{introduction,jdbcType=VARCHAR})"
    })
    int insert(Singer row);

    int insertSelective(Singer row);

    List<Singer> selectByExample(SingerExample example);

    @Select({
        "select",
        "id, name, sex, pic, birth, location, introduction",
        "from singer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.team.sion.mapper.SingerMapper.BaseResultMap")
    Singer selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("row") Singer row, @Param("example") SingerExample example);

    int updateByExample(@Param("row") Singer row, @Param("example") SingerExample example);

    int updateByPrimaryKeySelective(Singer row);

    @Update({
        "update singer",
        "set name = #{name,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=VARCHAR},",
          "pic = #{pic,jdbcType=VARCHAR},",
          "birth = #{birth,jdbcType=DATE},",
          "location = #{location,jdbcType=VARCHAR},",
          "introduction = #{introduction,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Singer row);
    @Select("select * from singer where id = #{id}")
    @ResultMap("com.team.sion.mapper.SingerMapper.BaseResultMap")
    Singer findById(Integer id);

    @Select("select id from singer where name = #{singerName}")
    Integer findByName(String singerName);
}